package com.dean.entity;

/**
 * @ClassName DbConnectInfo
 * @Description 数据库连接信息实体类
 * @Author dean
 * @Date 2021/10/3 7:03
 */
public class DeanDbConnInfo {
    private final String DRIVER="driver";
    private final String URL="url";
    private final String USERNAME="username";
    private final String PASSWORD="password";
    /**
     * 连接对象名称
     */
    private String connName;
    /**
     * 数据库连接驱动
     */
    private String driver;
    /**
     * 数据库连接url
     */
    private String url;
    /**
     * 数据库用户名
     */
    private String username;
    /**
     * 数据库连接密码
     */
    private String password;

    public String getConnName() {
        return connName;
    }

    public void setConnName(String connName) {
        this.connName = connName;
    }

    public String getDriver() {
        return driver;
    }

    public void setDriver(String driver) {
        this.driver = driver;
    }

    public String getUrl() {
        return url;
    }

    public void setUrl(String url) {
        this.url = url;
    }

    public String getUsername() {
        return username;
    }

    public void setUsername(String username) {
        this.username = username;
    }

    public String getPassword() {
        return password;
    }

    public void setPassword(String password) {
        this.password = password;
    }

    public void setFieldVal(String key,String val){
        if(key.endsWith(DRIVER)){
            setDriver(val);
        }else if(key.endsWith(URL)){
            setUrl(val);
        }else if(key.endsWith(USERNAME)){
            setUsername(val);
        }else if(key.endsWith(PASSWORD)){
            setPassword(val);
        }
    }

    @Override
    public String toString() {
        return "DbConnectInfo{" +
                "connName='" + connName + '\'' +
                ", driver='" + driver + '\'' +
                ", url='" + url + '\'' +
                ", username='" + username + '\'' +
                ", password='" + password + '\'' +
                '}';
    }
}
